home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / drivers / trid89n.asm < prev    next >
Assembly Source File  |  1993-12-06  |  4KB  |  226 lines

  1. ; This is file TRIDNT89.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. include grdriver.inc
  16. cseg    segment byte public 'code'
  17.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  18.  
  19.     dw    offset init_routine
  20.     dw    offset paging_routine
  21.     dw    GRD_VGA+GRD_8_PLANES+GRD_1024K+GRD_NO_RW
  22.  
  23. def_tw  dw    80    ; filled in by go32 if GO32 env. var. is set
  24. def_th  dw    25
  25. def_gw  dw    640
  26. def_gh  dw    480
  27.  
  28. ;--------------------------------------------------------------------------
  29. ; Entry: AX=mode selection
  30. ;        0=80x25 text
  31. ;        1=default text
  32. ;        2=text CX cols by DX rows
  33. ;        3=biggest text
  34. ;        4=320x200 graphics
  35. ;        5=default graphics
  36. ;        6=graphics CX width by DX height
  37. ;        7=biggest non-interlaced graphics
  38. ;        8=biggest graphics
  39. ;
  40. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  41. ;
  42. ; Exit:  CX=width (in pixels or characters)
  43. ;     DX=height
  44.  
  45. init_table    label    word
  46.     dw    offset init_0
  47.     dw    offset init_1
  48.     dw    offset init_2
  49.     dw    offset init_3
  50.     dw    offset init_4
  51.     dw    offset init_5
  52.     dw    offset init_6
  53.     dw    offset init_7
  54.     dw    offset init_8
  55.  
  56. init_routine    proc    far
  57.     cmp    ax,8
  58.     jbe    valid_req
  59.     ret
  60. valid_req:
  61.     shl    ax,1
  62.     mov    bx,ax
  63.     jmp    init_table[bx]
  64.  
  65. init_0: ; 80x25 text
  66.     mov    ax,3
  67.     int    10h
  68.     mov    cx,80
  69.     mov    dx,25
  70.     ret
  71.  
  72. init_1: ; default text
  73.     mov    cx,def_tw
  74.     mov    dx,def_th
  75.     jmp    init_2
  76.  
  77. init_2_table    label    word
  78.     dw    01h, 40, 25
  79.     dw    03h, 80, 25
  80.     dw    50h, 80, 30
  81.     dw    51h, 80, 43
  82.     dw    52h, 80, 60
  83.     dw    53h, 132, 25
  84.     dw    54h, 132, 30
  85.     dw    55h, 132, 43
  86.     dw    56h, 132, 60
  87. init_2_tend    label    word
  88.  
  89. init_2: ; CX*DX text
  90.     mov    si,offset init_2_table
  91. init_2a:
  92.     cmp    [si+2],cx
  93.     jb    init_2b
  94.     cmp    [si+4],dx
  95.     jb    init_2b
  96.     ; got a big enough one!
  97.     jmp    init_2c
  98. init_2b:
  99.     cmp    si,offset init_2_tend - 6
  100.     je    init_2c
  101.     add    si,6
  102.     jmp    init_2a
  103. init_2c:
  104.     mov    ax,[si]
  105.     push    si
  106.     int    10h
  107.     pop    si
  108.     mov    cx,[si+2]
  109.     mov    dx,[si+4]
  110.     ret
  111.  
  112. init_3: ; biggest text
  113.     mov    ax,[init_2_tend-6]
  114.     int    10h
  115.     mov    cx,[init_2_tend-4]
  116.     mov    dx,[init_2_tend-2]
  117.     ret
  118.  
  119. init_4: ; 320x200 graphics
  120.     mov    ax,13h
  121.     int    10h
  122.     mov    cx,320
  123.     mov    dx,200
  124.     ret
  125.  
  126. init_5: ; default graphics - should be 640x480 if supported
  127.     mov    cx,def_gw
  128.     mov    dx,def_gh
  129.     jmp    init_6
  130.  
  131. init_6_table    label    word
  132.     dw    13h, 320, 200
  133.     dw    5ch, 640, 400
  134.     dw    5dh, 640, 480
  135.     dw    5eh, 800, 600
  136.     dw    62h, 1024, 768
  137. init_6_tend    label    word
  138.  
  139. init_6: ; CX*DX graphics
  140.     mov    si,offset init_6_table
  141. init_6a:
  142.     cmp    [si+2],cx
  143.     jb    init_6b
  144.     cmp    [si+4],dx
  145.     jb    init_6b
  146.     ; got a big enough one!
  147.     jmp    init_6c
  148. init_6b:
  149.     cmp    si,offset init_6_tend - 6
  150.     je    init_6c
  151.     add    si,6
  152.     jmp    init_6a
  153. init_6c:
  154.     mov    ax,[si]
  155.     push    si
  156.     int    10h
  157.     pop    si
  158.     mov    cx,[si+2]
  159.     mov    dx,[si+4]
  160.     ret
  161.  
  162. init_7: ; biggest non-interlaced graphics
  163.     mov    ax,5eh
  164.     int    10h
  165.     mov    cx,800
  166.     mov    dx,600
  167.     ret
  168.  
  169. init_8: ; biggest graphics
  170.     mov    ax,62h
  171.     int    10h
  172.     mov    cx,1024
  173.     mov    dx,768
  174.     ret
  175.  
  176. init_routine    endp
  177.  
  178. ;--------------------------------------------------------------------------
  179. ; Entry: AH=read page
  180. ;     AL=write page
  181. ;
  182. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  183. ; This code must be relocatable and may not reference any data!
  184. ;
  185. ; Exit: VGA configured.
  186. ;    AX,BX,CX,DX,SI,DI may be trashed
  187. ;
  188. ; Code derived from VGAKIT version 3.5
  189. ;    Copyright 1988,89,90 John Bridges
  190.  
  191.     assume  ds:nothing, es:nothing
  192.  
  193. paging_routine  proc    far
  194.     mov    cx,ax        ;save page
  195.     mov    dx,3ceh        ;set pagesize to 64k
  196.     mov    al,6
  197.     out    dx,al
  198.     inc    dl
  199.     in    al,dx
  200.     dec    dl
  201.     or    al,4
  202.     mov    ah,al
  203.     mov    al,6
  204.     out    dx,ax
  205.  
  206.     mov    dl,0c4h        ;switch to BPS mode
  207.     mov    al,0bh
  208.     out    dx,al
  209.     inc    dl
  210.     in    al,dx
  211.     dec    dl
  212.  
  213.     mov    ah,cl
  214.     xor    ah,2
  215.     mov    dx,3c4h
  216.     mov    al,0eh
  217.     out    dx,ax
  218.     ret
  219.  
  220. paging_routine  endp
  221.  
  222. ;--------------------------------------------------------------------------
  223.  
  224. cseg    ends
  225.     end
  226.